# -*- coding: UTF-8 -*-
import requests

# 无参数get请求
# response = requests.get("https://api-v2.xdclass.net/api/rank/v1/hot_product")

# ----------------------------------------------------------------------------------------------
# 带参数get请求
# data = {"productId": 96}
# # https://api-v2.xdclass.net/api/product/v1/detail?productId=96
#
# response = requests.get("https://api-v2.xdclass.net/api/product/v1/detail", data)

# ----------------------------------------------------------------------------------------------
# 带参数post请求
data = {"phone": "xxxxxx", "pwd": "xxxxxx"}

response = requests.post("https://api-v2.xdclass.net/api/account/v1/login", data=data)

# 注意点： post提交方式有两个传参方式，针对不同的content-type, 务必要指定接口是哪个类型，表单提交还是json提交

# Content-Type: application/x-www-form-urlencoded
# requests.post("url", data=data)

# Content-Type: application/json
# requests.post("url", json=data)

# -----------------------------------------------------------------------------------------
# 传值token的请求
# params = {
#     "token": "dcloud-clienteyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ4ZGNsYXNzIiwiaGVhZF9pbWciOiJodHRwczovL2ZpbGUueGRjbGFzcy5uZXQvdXNlcl9maWxlLzIwMjIvZGVmYXVsdC84LmpwZWciLCJhY2NvdW50X2lkIjo2ODMzMzUxLCJ1c2VybmFtZSI6IuacgOW8uue8lueoizU2NzUiLCJyb2xlIjoiRk9SRVZFUl9WSVAiLCJtZWRhbCI6IkZPUkVWRVJfVklQLFRFU1RfT05FX1RPX09ORSIsImlhdCI6MTcyMjE0NjMwNSwiZXhwIjoxNzIyNzUxMTA1fQ.FrZDRI22VapaRFuQl228FVfa0TmPb-RFlfVsK_O7MTo"
# }
# 查询登录信息
# response = requests.get("https://api-v2.xdclass.net/api/account/v1/check_token", params=params)
# 查看广告顶图信息
# response = requests.get("https://api-v2.xdclass.net/api/banner/v1/list?location=home_top_ad", params=params)


# 收藏视频
# response = requests.post("https://api-v2.xdclass.net/api/product/v1/detail", data={"productId": 97}, params=params)

# 获取http状态码
print(response.status_code)

print(response.text)

print(response.content)

print(response.json())
